import Vue from 'vue'
import Router from 'vue-router'

import index from '@/pages/index'
import home from '@/pages/home'
//登陆
import login from '@/pages/login'
// 用户管理
import userList from '@/pages/userManagement/userList'
import blacklist from '@/pages/userManagement/blacklist'
import feedbackManagement from '@/pages/userManagement/feedbackManagement'
import accountGetBack from '@/pages/userManagement/accountGetBack'
//订单管理
import orderManagement from '@/pages/orderManagement/orderManagement'
import billsFlow from '@/pages/orderManagement/billsFlow'
import goldManagement from '@/pages/orderManagement/goldManagement'
import balanceManagement from '@/pages/orderManagement/balanceManagement'
import userWithdraw from '@/pages/orderManagement/userWithdraw'
//数据统计
import rechargeStatistics from '@/pages/dataStatistics/rechargeStatistics'
import registeredActive from '@/pages/dataStatistics/registeredActive'
import dailyChannelStatistics from '@/pages/dataStatistics/dailyChannelStatistics'
//内容管理
import userVideoUploadManagement from '@/pages/contentManagement/userVideoUploadManagement'
import backstageVideoUploadManagement from '@/pages/contentManagement/backstageVideoUploadManagement'
import communityNewsManagement from '@/pages/contentManagement/communityNewsManagement'
import topicCircle from '@/pages/contentManagement/topicCircle'
import findSearch from '@/pages/contentManagement/findSearch'
import videoClassManagement from '@/pages/contentManagement/videoClassManagement'
import videoKeyWord from '@/pages/contentManagement/videoKeyWord'
//运营管理
import bootAnimationManagement from '@/pages/operationManagement/bootAnimationManagement'
import imageAdManagement from '@/pages/operationManagement/imageAdManagement'
import videoAdManagement from '@/pages/operationManagement/videoAdManagement'
import membershipCardManagement from '@/pages/operationManagement/membershipCardManagement'
import goldPackageManagement from '@/pages/operationManagement/goldPackageManagement'
import payChannelsManagement from '@/pages/operationManagement/payChannelsManagement'
import redemptionCodeList from '@/pages/operationManagement/redemptionCodeList'
import channelsManagement from '@/pages/operationManagement/channelsManagement'
import invitationRulesManagement from '@/pages/operationManagement/invitationRulesManagement'
import invitationGroupManagement from '@/pages/operationManagement/invitationGroupManagement'
import systemNoticeManagement from '@/pages/operationManagement/systemNoticeManagement'
//系统管理
import systemConfig from '@/pages/systemManagement/systemConfig'
import versionUpgradManagement from '@/pages/systemManagement/versionUpgradManagement'
import rolesManagement from '@/pages/systemManagement/rolesManagement'
import administratorManagement from '@/pages/systemManagement/administratorManagement'
import domainNameManagement from '@/pages/systemManagement/domainNameManagement'
import permissionResourceManagement from '@/pages/systemManagement/permissionResourceManagement'
//系统监控
import errorLog from '@/pages/systemMonitor/errorLog'
import userBehaviorAnalysis from '@/pages/systemMonitor/userBehaviorAnalysis'
import operationLog from '@/pages/systemMonitor/operationLog'

Vue.use(Router)
export default new Router({
  mode: 'history',
  // base: '/wuwushop/',
  // mode: 'hash',
  routes: [
    //登陆
    {
      path: '/',
      name: 'login',
      component: login,
    },
    //首页
    {
      path: '/index',
      name: 'index',
      component: index,
      children: [{
          path: '/',
          name: 'home',
          component: home,
          meta: {
            title: "首页"
          }
        },
        // 用户管理
        //第一个用来把路由和elementui的menu顺序关联
        {
          path: '/1-1',
          redirect: '/userList',
          meta: {
            title: "用户列表"
          }
        },
        {
          path: '/userList',
          name: 'userList',
          component: userList,
          meta: {
            title: "用户列表"
          }
        },
        {
          path: '/1-2',
          redirect: '/blacklist',
          meta: {
            title: "黑名单列表"
          }
        },
        {
          path: '/blacklist',
          name: 'blacklist',
          component: blacklist,
          meta: {
            title: "黑名单列表"
          }
        },
        {
          path: '/1-3',
          redirect: '/feedbackManagement',
          meta: {
            title: "反馈管理"
          }
        },
        {
          path: '/feedbackManagement',
          name: 'feedbackManagement',
          component: feedbackManagement,
          meta: {
            title: "反馈管理"
          }
        },
        {
          path: '/1-4',
          redirect: '/accountGetBack',
          meta: {
            title: "账号找回"
          }
        },
        {
          path: '/accountGetBack',
          name: 'accountGetBack',
          component: accountGetBack,
          meta: {
            title: "账号找回"
          }
        },
        {
          path: '/2-1',
          redirect: '/orderManagement',
          meta: {
            title: "订单管理"
          }
        },
        {
          path: '/orderManagement',
          name: 'orderManagement',
          component: orderManagement,
          meta: {
            title: "订单管理"
          }
        },
        {
          path: '/2-2',
          redirect: '/billsFlow',
          meta: {
            title: "账单流水"
          }
        },
        {
          path: '/billsFlow',
          name: 'billsFlow',
          component: billsFlow,
          meta: {
            title: "账单流水"
          }
        },
        {
          path: '/2-3',
          redirect: '/goldManagement',
          meta: {
            title: "金币管理"
          }
        },
        {
          path: '/goldManagement',
          name: 'goldManagement',
          component: goldManagement,
          meta: {
            title: "金币管理"
          }
        },
        {
          path: '/2-4',
          redirect: '/balanceManagement',
          meta: {
            title: "余额管理"
          }
        },
        {
          path: '/balanceManagement',
          name: 'balanceManagement',
          component: balanceManagement,
          meta: {
            title: "余额管理"
          }
        },
        {
          path: '/2-5',
          redirect: '/userWithdraw',
          meta: {
            title: "余额管理"
          }
        },
        {
          path: '/userWithdraw',
          name: 'userWithdraw',
          component: userWithdraw,
          meta: {
            title: "余额管理"
          }
        },
        {
          path: '/3-1',
          redirect: '/rechargeStatistics',
          meta: {
            title: "充值统计"
          }
        },
        {
          path: '/rechargeStatistics',
          name: 'rechargeStatistics',
          component: rechargeStatistics,
          meta: {
            title: "充值统计"
          }
        },
        {
          path: '/3-2',
          redirect: '/registeredActive',
          meta: {
            title: "注册/活跃"
          }
        },
        {
          path: '/registeredActive',
          name: 'registeredActive',
          component: registeredActive,
          meta: {
            title: "注册/活跃"
          }
        },
        {
          path: '/3-3',
          redirect: '/dailyChannelStatistics',
          meta: {
            title: "每日渠道统计"
          }
        },
        {
          path: '/dailyChannelStatistics',
          name: 'dailyChannelStatistics',
          component: dailyChannelStatistics,
          meta: {
            title: "每日渠道统计"
          }
        },
        {
          path: '/4-1',
          redirect: '/userVideoUploadManagement',
          meta: {
            title: "用户视频上传管理"
          }
        },
        {
          path: '/userVideoUploadManagement',
          name: 'userVideoUploadManagement',
          component: userVideoUploadManagement,
          meta: {
            title: "用户视频上传管理"
          }
        },
        {
          path: '/4-2',
          redirect: '/backstageVideoUploadManagement',
          meta: {
            title: "后台视频上传管理"
          }
        },
        {
          path: '/backstageVideoUploadManagement',
          name: 'backstageVideoUploadManagement',
          component: backstageVideoUploadManagement,
          meta: {
            title: "后台视频上传管理"
          }
        },
        {
          path: '/4-3',
          redirect: '/communityNewsManagement',
          meta: {
            title: "社区动态管理"
          }
        },
        {
          path: '/communityNewsManagement',
          name: 'communityNewsManagement',
          component: communityNewsManagement,
          meta: {
            title: "社区动态管理"
          }
        },
        {
          path: '/4-4',
          redirect: '/topicCircle',
          meta: {
            title: "话题圈"
          }
        },
        {
          path: '/topicCircle',
          name: 'topicCircle',
          component: topicCircle,
          meta: {
            title: "话题圈"
          }
        },
        {
          path: '/4-5',
          redirect: '/findSearch',
          meta: {
            title: "发现及搜索"
          }
        },
        {
          path: '/findSearch',
          name: 'findSearch',
          component: findSearch,
          meta: {
            title: "发现及搜索"
          }
        },
        {
          path: '/4-6',
          redirect: '/videoClassManagement',
          meta: {
            title: "视频上传分类管理"
          }
        },
        {
          path: '/videoClassManagement',
          name: 'videoClassManagement',
          component: videoClassManagement,
          meta: {
            title: "视频上传分类管理"
          }
        },
        {
          path: '/4-7',
          redirect: '/videoKeyWord',
          meta: {
            title: "视频关键词"
          }
        },
        {
          path: '/videoKeyWord',
          name: 'videoKeyWord',
          component: videoKeyWord,
          meta: {
            title: "视频关键词"
          }
        },
        {
          path: '/5-1',
          redirect: '/bootAnimationManagement',
          meta: {
            title: "开机动画管理"
          }
        },
        {
          path: '/bootAnimationManagement',
          name: 'bootAnimationManagement',
          component: bootAnimationManagement,
          meta: {
            title: "开机动画管理"
          }
        },
        {
          path: '/5-2',
          redirect: '/imageAdManagement',
          meta: {
            title: "图片广告管理"
          }
        },
        {
          path: '/imageAdManagement',
          name: 'imageAdManagement',
          component: imageAdManagement,
          meta: {
            title: "图片广告管理"
          }
        },
        {
          path: '/5-3',
          redirect: '/videoAdManagement',
          meta: {
            title: "视频广告管理"
          }
        },
        {
          path: '/videoAdManagement',
          name: 'videoAdManagement',
          component: videoAdManagement,
          meta: {
            title: "视频广告管理"
          }
        },
        {
          path: '/5-4',
          redirect: '/membershipCardManagement',
          meta: {
            title: "会员卡管理"
          }
        },
        {
          path: '/membershipCardManagement',
          name: 'membershipCardManagement',
          component: membershipCardManagement,
          meta: {
            title: "会员卡管理"
          }
        },
        {
          path: '/5-5',
          redirect: '/goldPackageManagement',
          meta: {
            title: "金币套餐管理"
          }
        },
        {
          path: '/goldPackageManagement',
          name: 'goldPackageManagement',
          component: goldPackageManagement,
          meta: {
            title: "金币套餐管理"
          }
        },
        {
          path: '/5-6',
          redirect: '/payChannelsManagement',
          meta: {
            title: "付费渠道管理"
          }
        },
        {
          path: '/payChannelsManagement',
          name: 'payChannelsManagement',
          component: payChannelsManagement,
          meta: {
            title: "付费渠道管理"
          }
        },
        {
          path: '/5-7',
          redirect: '/redemptionCodeList',
          meta: {
            title: "兑换码列表"
          }
        },
        {
          path: '/redemptionCodeList',
          name: 'redemptionCodeList',
          component: redemptionCodeList,
          meta: {
            title: "兑换码列表"
          }
        },
        {
          path: '/5-8',
          redirect: '/channelsManagement',
          meta: {
            title: "渠道管理"
          }
        },
        {
          path: '/channelsManagement',
          name: 'channelsManagement',
          component: channelsManagement,
          meta: {
            title: "渠道管理"
          }
        },
        {
          path: '/5-9',
          redirect: '/invitationRulesManagement',
          meta: {
            title: "邀请规则管理"
          }
        },
        {
          path: '/invitationRulesManagement',
          name: 'invitationRulesManagement',
          component: invitationRulesManagement,
          meta: {
            title: "邀请规则管理"
          }
        },
        {
          path: '/5-10',
          redirect: '/invitationGroupManagement',
          meta: {
            title: "邀请群管理"
          }
        },
        {
          path: '/invitationGroupManagement',
          name: 'invitationGroupManagement',
          component: invitationGroupManagement,
          meta: {
            title: "邀请群管理"
          }
        },
        {
          path: '/5-11',
          redirect: '/systemNoticeManagement',
          meta: {
            title: "系统公告管理"
          }
        },
        {
          path: '/systemNoticeManagement',
          name: 'systemNoticeManagement',
          component: systemNoticeManagement,
          meta: {
            title: "系统公告管理"
          }
        },
        {
          path: '/6-1',
          redirect: '/systemConfig',
          meta: {
            title: "系统配置"
          }
        },
        {
          path: '/systemConfig',
          name: 'systemConfig',
          component: systemConfig,
          meta: {
            title: "系统配置"
          }
        },
        {
          path: '/6-2',
          redirect: '/versionUpgradManagement',
          meta: {
            title: "版本升级管理"
          }
        },
        {
          path: '/versionUpgradManagement',
          name: 'versionUpgradManagement',
          component: versionUpgradManagement,
          meta: {
            title: "版本升级管理"
          }
        },
        {
          path: '/6-3',
          redirect: '/permissionResourceManagement',
          meta: {
            title: "权限资源管理"
          }
        },
        {
          path: '/permissionResourceManagement',
          name: 'permissionResourceManagement',
          component: permissionResourceManagement,
          meta: {
            title: "权限资源管理"
          }
        },
        {
          path: '/6-4',
          redirect: '/rolesManagement',
          meta: {
            title: "角色管理"
          }
        },
        {
          path: '/rolesManagement',
          name: 'rolesManagement',
          component: rolesManagement,
          meta: {
            title: "角色管理"
          }
        },
        {
          path: '/6-5',
          redirect: '/administratorManagement',
          meta: {
            title: "管理员管理"
          }
        },
        {
          path: '/administratorManagement',
          name: 'administratorManagement',
          component: administratorManagement,
          meta: {
            title: "管理员管理"
          }
        },
        {
          path: '/6-6',
          redirect: '/domainNameManagement',
          meta: {
            title: "域名管理"
          }
        },
        {
          path: '/domainNameManagement',
          name: 'domainNameManagement',
          component: domainNameManagement,
          meta: {
            title: "域名管理"
          }
        },
        {
          path: '/7-1',
          redirect: '/errorLog',
          meta: {
            title: "错误日志"
          }
        },
        {
          path: '/errorLog',
          name: 'errorLog',
          component: errorLog,
          meta: {
            title: "错误日志"
          }
        },
        {
          path: '/7-2',
          redirect: '/userBehaviorAnalysis',
          meta: {
            title: "用户行为分析"
          }
        },
        {
          path: '/userBehaviorAnalysis',
          name: 'userBehaviorAnalysis',
          component: userBehaviorAnalysis,
          meta: {
            title: "用户行为分析"
          }
        },
        {
          path: '/7-3',
          redirect: '/operationLog',
          meta: {
            title: "用户行为分析"
          }
        },
        {
          path: '/operationLog',
          name: 'operationLog',
          component: operationLog,
          meta: {
            title: "用户行为分析"
          }
        },
      ],
    },

  ],
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return {
        x: 0,
        y: 0
      }
    }
    if (to.hash) {
      return {
        selector: to.hash
      }
    }
  },

  beforeRouteEnter(to, from, next) {
    // 这个地方的代码是在create之前调用
    next(vm => {
      if (to.meta.isShow > from.meta.index) {} else if (to.meta.index < from.meta.index) {} else {}
    })

  },
})
